package com.supor.aiot.mine.ui.cooking;

import androidx.annotation.Nullable;
import androidx.core.widget.NestedScrollView;
import androidx.lifecycle.Observer;

import android.Manifest;
import android.content.Intent;
import android.media.MediaMetadataRetriever;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.android.baseconfig.base.GlideApp;
import com.android.baseconfig.base.RxBus3;
import com.android.baseconfig.common.rxpermissions2.RxPermissions;
import com.android.baseconfig.common.utils.Logc;
import com.android.baseconfig.common.utils.ToastUtils;
import com.android.baseconfig.common.views.AppBasicDialog;
import com.supor.aiot.common.app.Constants;
import com.supor.aiot.common.app.SuporPresenter;
import com.supor.aiot.common.arouter.PathUrl;
import com.supor.aiot.common.base.BaseMVVMEnhanceActivity;
import com.supor.aiot.common.entity.Result;
import com.supor.aiot.common.entity.UploadResultBean;
import com.supor.aiot.common.helper.ActivityHelper;
import com.supor.aiot.common.utils.NotNullUtils;
import com.supor.aiot.mine.R;
import com.supor.aiot.mine.bean.CookingMediaSelectBean;
import com.supor.aiot.mine.bean.RecipeEvalBean;
import com.supor.aiot.mine.databinding.ActivityCookingEvaluationBinding;
import com.supor.aiot.mine.helper.FeedbackImageCache;
import com.supor.aiot.mine.ui.adapter.CookingCommXGraidAdapter;
import com.supor.aiot.mine.ui.feedback.ImageGridActivity;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;

@Route(path = PathUrl.HomeMine.PATH_MINE_COOKING_EVAL)
public class CookingEvaluationActivity extends BaseMVVMEnhanceActivity<CookingRecordModel,
        ActivityCookingEvaluationBinding> implements View.OnClickListener {

    private String recordId;
    private String recordName;
    private String recordCover;

    private int satisfaction;
    private AppBasicDialog checkDialog;

//    public static void startActivity(Context mContext, String recordId, String cover, String name) {
//        Intent intent = new Intent(mContext, CookingEvaluationActivity.class);
//        intent.putExtra("RECORD_ID", recordId);
//        intent.putExtra("RECORD_COVER", cover);
//        intent.putExtra("RECORD_NAME", name);
//        mContext.startActivity(intent);
//    }

    private RxPermissions rxPermissions;
    private AppBasicDialog commonDialog;
    private CookingCommXGraidAdapter cookingCommXGraidAdapter;

    @Override
    protected void initView() {
        super.initView();
        bindingView.flPageBack.setOnClickListener(view -> finish());
        if (null != getIntent()) {
            recordId = getIntent().getStringExtra("COOKING_EVAL_ID");
            recordName = getIntent().getStringExtra("COOKING_EVAL_NAME");
            recordCover = getIntent().getStringExtra("COOKING_EVAL_IMG");
        }

        bindingView.nScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                Logc.d("scrollX = " + scrollX + " scrollY = " + scrollY + " oldScrollX = " + oldScrollX + " oldScrollY = " + oldScrollY);
                if (scrollY == 0) {
                    bindingView.flPageTitle.setBackgroundColor(0x00ffffff);
                    bindingView.tvPageTitleStr.setTextColor(0xffffffff);
                    bindingView.ivPageBackBtn.setBackgroundResource(R.mipmap.ic_cooking_record_back);
                    bindingView.viewGap.setVisibility(View.GONE);
                } else {
                    bindingView.flPageTitle.setBackgroundColor(0xffffffff);
                    bindingView.tvPageTitleStr.setTextColor(0xFF333333);
                    bindingView.ivPageBackBtn.setBackgroundResource(R.mipmap.ic_cooking_eval_page_back);
                    bindingView.viewGap.setVisibility(View.VISIBLE);
                }
            }
        });
        GlideApp.with(this)
                .load(recordCover)
                .into(bindingView.ivCookingImg);
        bindingView.tvCookingName.setText(NotNullUtils.getNotNullValue(recordName));
        bindingView.llDynamicSyn.setOnClickListener(this);
        bindingView.tvSubmit.setOnClickListener(this);
        bindingView.llOrdinary.setOnClickListener(this);
        bindingView.llNotbad.setOnClickListener(this);
        bindingView.llFantastic.setOnClickListener(this);
        rxPermissions = new RxPermissions(this);
        ArrayList<CookingMediaSelectBean> mediaData = new ArrayList<>();
        CookingMediaSelectBean cookingMediaSelectBean = new CookingMediaSelectBean();
        cookingMediaSelectBean.setItemType(CookingMediaSelectBean.TYPE_ITEM_UPLOAD_IMG);
        mediaData.add(cookingMediaSelectBean);
        CookingMediaSelectBean cookingMediaSelectBean2 = new CookingMediaSelectBean();
        cookingMediaSelectBean2.setItemType(CookingMediaSelectBean.TYPE_ITEM_UPLOAD_VIDEO);
        mediaData.add(cookingMediaSelectBean2);
        cookingCommXGraidAdapter = new CookingCommXGraidAdapter(this,
                mediaData, R.layout.item_cooking_comm_media);
        cookingCommXGraidAdapter.setOnItemChildClickListener(new CookingCommXGraidAdapter.OnItemChildClickListener() {
            @Override
            public void onCLick(View view, CookingMediaSelectBean item, int position) {
                switch (item.getItemType()) {
                    case CookingMediaSelectBean.TYPE_ITEM_IMG:
                        if (view.getId() == R.id.fl_del) {
                            removeImageItem(position);
                        }
                        break;
                    case CookingMediaSelectBean.TYPE_ITEM_VIDEO:
                        if (view.getId() == R.id.fl_del) {
                            removeVideoItem(position);
                        }
                        break;
                    case CookingMediaSelectBean.TYPE_ITEM_UPLOAD_IMG:
                        checkImg();
                        break;
                    case CookingMediaSelectBean.TYPE_ITEM_UPLOAD_VIDEO:
                        checkVideo();
                        break;
                }
            }
        });

        bindingView.xgrid.setAdapter(cookingCommXGraidAdapter);

        bindingView.etContent.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                bindingView.tvTextNum.setText(charSequence.length() + "/500");
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
//        changeTagLv(3);
    }

    private void changeTagLv(int lv) {//满意度 1一般；2还不错；3太赞了
        if (satisfaction == lv) {
            return;
        }
        satisfaction = lv;
        bindingView.ivSubmit.setAlpha(1f);
        bindingView.warpLinearLayout.removeAllViews();
        bindingView.warpLinearLayout.setVisibility(View.VISIBLE);
        bindingView.tvLevelTag.setVisibility(View.VISIBLE);
        switch (lv) {
            case 1:
                addTag("不够入味");
                addTag("咸淡不佳");
                addTag("过于甜口");
                addTag("步骤复杂");
                addTag("用时太久");
                addTag("配料太多");
                addTag("裹色不均");
                addTag("没有香味");
                addTag("食材搅碎");
                bindingView.ivOrdinary.setVisibility(View.GONE);
                bindingView.ivOrdinarySelected.setVisibility(View.VISIBLE);

                bindingView.ivNotbad.setVisibility(View.VISIBLE);
                bindingView.ivNotbadSelected.setVisibility(View.GONE);

                bindingView.ivFantastic.setVisibility(View.VISIBLE);
                bindingView.ivFantasticSelected.setVisibility(View.GONE);

                bindingView.tvOrdinary.setTextColor(0xff16BF86);
                bindingView.tvNotbad.setTextColor(0xff333333);
                bindingView.tvFantastic.setTextColor(0xff333333);
                bindingView.tvLevelTag.setText("“一般般，以下方面能做的更好“");
                break;
            case 2:
                addTag("咸甜适中");
                addTag("值得一尝");
                addTag("色香味佳");
                addTag("步骤简单");
                addTag("快手省时");
                addTag("简单易做");
                addTag("色泽不错");
                addTag("香气四溢");
                addTag("品味俱佳");
                bindingView.ivOrdinary.setVisibility(View.VISIBLE);
                bindingView.ivOrdinarySelected.setVisibility(View.GONE);

                bindingView.ivNotbad.setVisibility(View.GONE);
                bindingView.ivNotbadSelected.setVisibility(View.VISIBLE);

                bindingView.ivFantastic.setVisibility(View.VISIBLE);
                bindingView.ivFantasticSelected.setVisibility(View.GONE);

                bindingView.tvOrdinary.setTextColor(0xff333333);
                bindingView.tvNotbad.setTextColor(0xff16BF86);
                bindingView.tvFantastic.setTextColor(0xff333333);
                bindingView.tvLevelTag.setText("“还不错，还有哪些点待提升呢？“");
                break;
            case 3:
                addTag("大厨水准");
                addTag("下饭神器");
                addTag("美味绝绝子");
                addTag("省时省力");
                addTag("操作方便");
                addTag("配料比精准");
                addTag("秀色可餐");
                addTag("香气扑鼻");
                addTag("菜色新颖");

                bindingView.ivOrdinary.setVisibility(View.VISIBLE);
                bindingView.ivOrdinarySelected.setVisibility(View.GONE);

                bindingView.ivNotbad.setVisibility(View.VISIBLE);
                bindingView.ivNotbadSelected.setVisibility(View.GONE);

                bindingView.ivFantastic.setVisibility(View.GONE);
                bindingView.ivFantasticSelected.setVisibility(View.VISIBLE);

                bindingView.tvOrdinary.setTextColor(0xff333333);
                bindingView.tvNotbad.setTextColor(0xff333333);
                bindingView.tvFantastic.setTextColor(0xff16BF86);
                bindingView.tvLevelTag.setText("“太赞了，我想夸夸幕后的TA“");
                break;
        }
    }

    @Override
    protected void initData() {
        super.initData();
        viewModel.getImgUrlArray().observe(this, new Observer<List<UploadResultBean>>() {
            @Override
            public void onChanged(List<UploadResultBean> uploadResultBeans) {
                if (uploadResultBeans.size() > 0) {
                    StringBuilder imgUrls = new StringBuilder();
                    for (int i = 0; i < uploadResultBeans.size(); i++) {
                        imgUrls.append(uploadResultBeans.get(i).getFileUrl());
                        if (i != uploadResultBeans.size() - 1) {
                            imgUrls.append(",");
                        }
                    }
                    submitData(imgUrls.toString(), "");
                }
            }
        });
        viewModel.getVideoUrlArray().observe(this, new Observer<List<UploadResultBean>>() {
            @Override
            public void onChanged(List<UploadResultBean> uploadResultBeans) {
                if (uploadResultBeans.size() > 0) {
                    submitData("", uploadResultBeans.get(0).getFileUrl());
                }
            }
        });
        viewModel.getUploadResult().observe(this, new Observer<Result>() {
            @Override
            public void onChanged(Result result) {
                closeLoading();
            }
        });
        viewModel.getEvalSubmitResult().observe(this, new Observer<Result<RecipeEvalBean>>() {
            @Override
            public void onChanged(Result<RecipeEvalBean> recipeEvalBeanResult) {
                closeLoading();
                ToastUtils.getInstance().showToast(CookingEvaluationActivity.this, "评论成功");
                RxBus3.getInstance().post(Constants.Tag.COOKING_EVAL, Constants.Value.SUCCESS);
                SuporPresenter.getInstance().reportRecipeCommInfo(recordId, satisfaction);
                finish();
            }
        });
    }

    private void checkVideo() {
        rxPermissions.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .to(bindDestoryAutoDispose())
                .subscribe(aBoolean -> {
                    if (aBoolean) {
                        FeedbackImageCache.getInstance().cleanBimp();
                        Intent intent = new Intent(this, ImageGridActivity.class);
                        intent.putExtra(Constants.Key.NUM, 1);
                        // type 0-photo|1-video
                        intent.putExtra(Constants.Key.param_type, 1);
                        startActivityForResult(intent, Constants.REQUEST_CODE);
                    } else {
                        Logc.i("permission request: failed");
                        showDialog();
                    }
                });
    }

    private void checkImg() {
        int num = 9;
        for (CookingMediaSelectBean datum : cookingCommXGraidAdapter.getData()) {
            if (datum.getItemType() == CookingMediaSelectBean.TYPE_ITEM_IMG) {
                num--;
            }
        }
        if (num > 0) {
            int finalNum = num;
            rxPermissions.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                    .to(bindDestoryAutoDispose())
                    .subscribe(aBoolean -> {
                        if (aBoolean) {
                            FeedbackImageCache.getInstance().cleanBimp();
                            Intent intent = new Intent(this, ImageGridActivity.class);
                            // max number
                            intent.putExtra(Constants.Key.NUM, finalNum);
                            // type 0-photo|1-video
                            intent.putExtra(Constants.Key.param_type, 0);
                            startActivityForResult(intent, Constants.REQUEST_CODE);
                        } else {
                            Logc.i("permission request: failed");
                            showDialog();
                        }
                    });
        }
    }

    private void addTag(String tag) {
        if (TextUtils.isEmpty(tag)) {
            return;
        }
        View tagRootView = View.inflate(this, R.layout.tag_cooking_eval, null);
        TextView tagView = tagRootView.findViewById(R.id.tv_content);
        tagView.setText(tag);
        tagView.setTag(R.id.tag_id_state, 0);
        tagView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if ((Integer) view.getTag(R.id.tag_id_state) == 0) {
                    view.setTag(R.id.tag_id_state, 1);
                    view.setBackgroundResource(R.drawable.shape_cooking_eval_tag_light_bg);
                    ((TextView) view).setTextColor(0xff16bf86);
                } else {
                    view.setTag(R.id.tag_id_state, 0);
                    view.setBackgroundResource(R.drawable.shape_cooking_eval_tag_bg);
                    ((TextView) view).setTextColor(0xFF333333);
                }
            }
        });
        bindingView.warpLinearLayout.addView(tagRootView);
    }

    protected void showDialog() {
        if (commonDialog != null && commonDialog.isShowing()) {
            commonDialog.dismiss();
        }
        AppBasicDialog.Builder builder = new AppBasicDialog.Builder(this, false);
        builder.setTitle(R.string.permission_storage_title);
        builder.setMessage(R.string.permission_storage_msg);
        builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
        builder.setPositiveButton(R.string.go_settings, (dialog, which) -> {
            ActivityHelper.startAppSettings(this, Constants.REQUEST_CODE2);
            dialog.dismiss();
        });
        commonDialog = builder.create();
        commonDialog.setCancelable(false);
        commonDialog.show();
    }

    private void addImageItem(List<String> paths) {
        if (null != paths && paths.size() > 0) {
            ArrayList<CookingMediaSelectBean> list = new ArrayList<>();
            for (String path : paths) {
                CookingMediaSelectBean cookingMediaSelectBean = new CookingMediaSelectBean();
                cookingMediaSelectBean.setPath(path);
                cookingMediaSelectBean.setItemType(CookingMediaSelectBean.TYPE_ITEM_IMG);
                list.add(cookingMediaSelectBean);
            }
            cookingCommXGraidAdapter.getData().addAll(0, list);

            if (cookingCommXGraidAdapter.getData().size() > 1) {
                if (cookingCommXGraidAdapter.getData().get(cookingCommXGraidAdapter.getData().size() - 1).getItemType()
                        == CookingMediaSelectBean.TYPE_ITEM_UPLOAD_VIDEO) {
                    cookingCommXGraidAdapter.getData().remove(cookingCommXGraidAdapter.getData().size() - 1);
                }
            }

            if (cookingCommXGraidAdapter.getData().size() > 9) {
                List<CookingMediaSelectBean> tplist = new ArrayList<>();
                tplist.addAll(cookingCommXGraidAdapter.getData().subList(0, 9));
                cookingCommXGraidAdapter.replaceAll(tplist);
            }
            cookingCommXGraidAdapter.notifyDataSetChanged();
        }
    }

    private void addVideoItem(List<String> paths) {
        if (null != paths && paths.size() > 0) {
            MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
            mediaMetadataRetriever.setDataSource(paths.get(0));
            long duration = Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
            System.out.println("vide_duration_debug: " + duration);
            if (duration > 15000) {
                ToastUtils.getInstance().showToast(this, "请选择时长15秒以内的视频");
                return;
            }
            long size = 0;
            File file = new File(paths.get(0));
            if (file.exists()) {
                FileInputStream fis = null;
                try {
                    fis = new FileInputStream(file);
                    size = fis.available();
                    fis.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (size > 49 * 1024 * 1024) {
                ToastUtils.getInstance().showToast(this, "文件过大，请选择50mb以内的文件");
                return;
            }

            CookingMediaSelectBean cookingMediaSelectBean = new CookingMediaSelectBean();
            cookingMediaSelectBean.setPath(paths.get(0));
            cookingMediaSelectBean.setItemType(CookingMediaSelectBean.TYPE_ITEM_VIDEO);
            cookingCommXGraidAdapter.getData().clear();
            cookingCommXGraidAdapter.getData().add(cookingMediaSelectBean);
            cookingCommXGraidAdapter.notifyDataSetChanged();
        }
    }

    private void removeVideoItem(int position) {
        ArrayList<CookingMediaSelectBean> mediaData = new ArrayList<>();
        CookingMediaSelectBean cookingMediaSelectBean = new CookingMediaSelectBean();
        cookingMediaSelectBean.setItemType(CookingMediaSelectBean.TYPE_ITEM_UPLOAD_IMG);
        mediaData.add(cookingMediaSelectBean);
        CookingMediaSelectBean cookingMediaSelectBean2 = new CookingMediaSelectBean();
        cookingMediaSelectBean2.setItemType(CookingMediaSelectBean.TYPE_ITEM_UPLOAD_VIDEO);
        mediaData.add(cookingMediaSelectBean2);
        cookingCommXGraidAdapter.replaceAll(mediaData);
    }

    private void removeImageItem(int position) {
        if (cookingCommXGraidAdapter.getData().size() > position
                && cookingCommXGraidAdapter.getData().get(position).getItemType() == CookingMediaSelectBean.TYPE_ITEM_IMG) {
            cookingCommXGraidAdapter.getData().remove(position);
        }
        if (cookingCommXGraidAdapter.getData().size() <= 9 && cookingCommXGraidAdapter.getData().size() > 0
                && cookingCommXGraidAdapter.getData().get(cookingCommXGraidAdapter.getData().size() - 1).getItemType() != CookingMediaSelectBean.TYPE_ITEM_UPLOAD_IMG) {
            CookingMediaSelectBean cookingMediaSelectBean = new CookingMediaSelectBean();
            cookingMediaSelectBean.setItemType(CookingMediaSelectBean.TYPE_ITEM_UPLOAD_IMG);
            cookingCommXGraidAdapter.getData().add(cookingMediaSelectBean);
        }
        if (cookingCommXGraidAdapter.getData().size() > 0 && cookingCommXGraidAdapter.getData().get(0).getItemType() != CookingMediaSelectBean.TYPE_ITEM_IMG) {
            ArrayList<CookingMediaSelectBean> mediaData = new ArrayList<>();
            CookingMediaSelectBean cookingMediaSelectBean = new CookingMediaSelectBean();
            cookingMediaSelectBean.setItemType(CookingMediaSelectBean.TYPE_ITEM_UPLOAD_IMG);
            mediaData.add(cookingMediaSelectBean);
            CookingMediaSelectBean cookingMediaSelectBean2 = new CookingMediaSelectBean();
            cookingMediaSelectBean2.setItemType(CookingMediaSelectBean.TYPE_ITEM_UPLOAD_VIDEO);
            mediaData.add(cookingMediaSelectBean2);
            cookingCommXGraidAdapter.getData().clear();
            cookingCommXGraidAdapter.getData().addAll(mediaData);
        }
        cookingCommXGraidAdapter.notifyDataSetChanged();
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == Constants.REQUEST_CODE) {
            if (FeedbackImageCache.getInstance().getDrr().size() > 0) {
                if (resultCode == 0) {
                    // itemList.clear();
                    List<String> paths = FeedbackImageCache.getInstance().getDrr();
                    addImageItem(paths);
                } else if (resultCode == 1) {
                    List<String> paths = FeedbackImageCache.getInstance().getDrr();
                    addVideoItem(paths);
                }
            }
        }
    }

    @Override
    public void onClick(View view) {
        if (view == bindingView.tvSubmit) {
            if (satisfaction == 0) {
                ToastUtils.getInstance().showToast(this, "请选择评价哦～");
                return;
            }
            String supplementary = bindingView.etContent.getText().toString().trim();
            if (supplementary.length() == 1) {
                ToastUtils.getInstance().showToast(this, "评论内容至少输入2个字哦～");
                return;
            }

            if (cookingCommXGraidAdapter.getData().size() > 0) {
                if (cookingCommXGraidAdapter.getData().get(0).getItemType() == CookingMediaSelectBean.TYPE_ITEM_IMG) {
                    ArrayList<String> tpData = new ArrayList<>();
                    for (CookingMediaSelectBean datum : cookingCommXGraidAdapter.getData()) {
                        if (datum.getItemType() == CookingMediaSelectBean.TYPE_ITEM_IMG) {
                            tpData.add(datum.getPath());
                        }
                    }
                    viewModel.uploadPhoto(tpData);
                    showLoading();
                } else if (cookingCommXGraidAdapter.getData().get(0).getItemType() == CookingMediaSelectBean.TYPE_ITEM_VIDEO) {
                    ArrayList<String> tpData = new ArrayList<>();
                    tpData.add(cookingCommXGraidAdapter.getData().get(0).getPath());
                    viewModel.uploadVideo(tpData);
                    showLoading();
                } else {
                    bindingView.slideBtn.setOpen(false);
                    submitData("", "");
//                    showDeleteDialog("提示", "还没选择图片或视频，是否提交评价？");
                }
            }
        } else if (view.getId() == R.id.ll_dynamic_syn) {
            bindingView.slideBtn.setOpen(!bindingView.slideBtn.isOpen());
        } else if (view == bindingView.llOrdinary) {
            changeTagLv(1);
        } else if (view == bindingView.llNotbad) {
            changeTagLv(2);
        } else if (view == bindingView.llFantastic) {
            changeTagLv(3);
        }
    }

    private void submitData(String evaluateImage, String evaluateVideo) {
        //            String logId,//烹饪记录id
//            int satisfaction,//满意度 1一般；2还不错；3太赞了
//            String satisfiedLabels,//满意度标签
//            String supplementary,//说点什么
//            String evaluateImage,//图片
//            String evaluateVideo//视频
        if (satisfaction == 0) {
            return;
        }
        int childCount = bindingView.warpLinearLayout.getChildCount();
        StringBuilder satisfiedLabels = new StringBuilder();

        for (int i = 0; i < childCount; i++) {
            if (bindingView.warpLinearLayout.getChildAt(i) instanceof TextView) {
                TextView tagView = (TextView) bindingView.warpLinearLayout.getChildAt(i);
                if (null != tagView.getTag(R.id.tag_id_state) && (Integer) tagView.getTag(R.id.tag_id_state) == 1) {
                    satisfiedLabels.append(tagView.getText());
                    satisfiedLabels.append(",");
                }
            }
        }
        String strlbs;
        if (satisfiedLabels.length() > 1) {
            strlbs = satisfiedLabels.substring(0, satisfiedLabels.length() - 1);
        } else {
            strlbs = satisfiedLabels.toString();
        }

        viewModel.submitRecipeEval(recordId, satisfaction, strlbs,
                bindingView.etContent.getText().toString().trim(),
                evaluateImage, evaluateVideo, bindingView.slideBtn.isOpen() ? 1 : 0,
                bindDestoryAutoDispose()
        );
    }

    private void showDeleteDialog(String title, String message) {
        if (checkDialog != null && checkDialog.isShowing()) {
            checkDialog.dismiss();
        }
        AppBasicDialog.Builder builder = new AppBasicDialog.Builder(this, false);
        builder.setTitle(title);
        builder.setMessage(message);
        builder.setPositiveButton(R.string.sure, (dialog, which) -> {
            bindingView.slideBtn.setOpen(false);
            submitData("", "");
            dialog.cancel();
        });
        builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.cancel());
        checkDialog = builder.create();
        checkDialog.setCancelable(false);
        checkDialog.show();
    }
}